package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.http.response.SysMsgResponse;
import com.qf.flash.mvp.contract.SysMsgContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class SysMsgPresenter extends BasePresenter<SysMsgContract.View> implements SysMsgContract.Presenter {
    @Override
    public void getSysMsg(int page, int size) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .SYS_MSG(uid,page, size)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<SysMsgResponse>>>(mRootView, false) {
                    @Override
                    public void onSuccess(BaseResponse<List<SysMsgResponse>> response) {
                        mRootView.setSysMsgData(response.getData(), response.getTotalPage());
                    }
                })

        );
    }
}
